﻿using System;
using FadeGameFramework.UI;
using SharpDX;

namespace FadeGameFramework.DevTest
{
    internal static class Program
    {
        private static TestSprite[] testSprites;

        [STAThread]
        private static void Main(string[] args) {
            ViewTest();
            GuiTest();
        }

        private static void GuiTest() {
            using (var game = new Game(1024, 768, "FadeGameFramework GUI Demo")) {
                game.OnRender += GuiTest_OnRender;
                var button = new Button(
                    new[] {
                        "Content/ButtonNormal.png", "Content/ButtonEnter.png", "Content/ButtonClick.png"
                    }) {
                        Position = new Point(100, 100),
                        Zorder = 100
                    };
                button.AddToManager();
                game.Run();
            }
        }

        private static void GuiTest_OnRender(RenderArgs e) {
            var game = Game.Instance;
            game.RenderTarget.Clear(Color.Beige);
            game.ControlManager.Draw();
            game.DebugDrawer.Draw();
        }

        private static void ViewTest() {
            using (var game = new Game(1024, 768, "FadeGameFramework Demo")) {
                LoadViewTestContents();
                testSprites = new TestSprite[1000];
                var random = new Random();
                for (var i = 0; i < testSprites.Length; i++) {
                    testSprites[i] = new TestSprite {
                        Position = new Vector2(random.Next(100, 1000), random.Next(100, 1000))
                    };
                }
                game.SpriteManager.AddSprite(testSprites);
                game.OnRender += ViewTest_OnRender;
                game.Run();
            }
        }

        private static void LoadViewTestContents() {
            var game = Game.Instance;
            game.ResourcesManager.LoadBitmapFromFile("Content/grossini.png");
            game.ResourcesManager.LoadBitmapFromFile("Content/Sasuke-fireball.png");
        }

        private static void ViewTest_OnRender(RenderArgs e) {
            var game = Game.Instance;
            game.RenderTarget.Clear(Color.White);
            game.DebugDrawer.Draw();
            game.SpriteManager.Draw();
        }
    }
}